package com.meego.common.timer;

public class Midnight {

    private static MultiEvent midnight;

    public static void add(TimeListener aListener) {
        if (midnight == null) {
            initTimer();
        }
        midnight.addListener(aListener);
    }

    public static void remove(TimeListener aListener) {
        if (midnight == null) {
            initTimer();
        }
        midnight.removeListener(aListener);
    }

    private static synchronized void initTimer() {
        if (midnight == null) {
            midnight = new MultiEvent(new DailyEvent(0, 0, 0, false));
            EventTimer.getInstance().addTimedEvent("midnight", midnight);
        }
    }
}
